home *** CD-ROM | disk | FTP | other *** search
- #
- #
- |---------------B A T C H L R N H E L P S Y S T E M-----------------|
- |commandS:Various paramters used in commands, including batch cmds. |
- |use:To modify or otherwise change the effect of the command. |
- | |
- |how:Type <command> <parameter> or use parameters in batch files. |
- | |
- |examples:There are many batch files on this disk you can study to |
- | see how Parameters work. Also see examples included below. |
- | |
- |explanation:Parameters are extra pieces of information that you type |
- | after many DOS cmnds.or in batch file instructions.DIR B:/W,for ex- |
- | ample, illustrates modification of the DOS command DIR. By adding |
- | the parameters B: and /W you are modifying basic operation of the |
- | command. You pass parameters to batch files the same way--by typing |
- | the information after the batch command, but BEFORE typing the |
- | balance of the information. This process is called "testing". This |
- | will seem complicated at first, but once you get the hang of it you |
- | will wonder why you didn't know about batch processing (replaceable)|
- | parameters before. Parameters may be used any place in a batch file |
- | they are needed to "test" for the presence of something you typed, |
- | (or DIDN'T TYPE) at the prompt (it WILL get clearer!). |
- | The secret to understanding batch file parameters is to slowly work |
- | into the subject. The batch processing file uses parameters in sev- |
- | eral ways as it is being run and this (at first) makes comprehension|
- | difficult. "Markers" are used within the batch file as "signals" as |
- | to wh/parameter goes where. Markers are comprised of a percent sign |
- | (%) and a single digit between 0 and 9 (that's ten markers in use |
- | at any one time--remember that zero is a number). The %0 is ALWAYS |
- | the NAME OF THE BATCH PROCESSING FILE! As if it wasn't confusing |
- | enough already, many manuals refer to markers as simply "variables".|
- | The name, obviously, is not as important as the concept. To cover |
- | this, however, we also have a file called:VAR.HLP. It covers the |
- | fact that THERE IS a difference between parameters and variables. |
- | |
- | examples: Assume that a batch file named COLORGO.BAT is on the cur- |
- | rent drive. This file contains ONLY a single command: |
- | ECHO %0 %1 %2 %3 [ECHO shows messages on the screen]. |
- | If, at the DOS prompt, you typed: COLORGO Red Blue Green THAT cmd. |
- | would recognize that FOUR parameters were passed to the batch file. |
- | The batch file via the ECHO would display them on the screen in the |
- | order received (0=colorgo{name of .BAT file}; %1=red; %2=blue & %3= |
- | green) in the form you typed in. The parameters and markers were |
- | related,(to restate),as follows... ECHO COLORGO Red Blue Green |
- | %0 %1 %2 %3 |
- | TO EXPLAIN REPLACEABLE PARAMETERS ANOTHER WAY: |
- | You can include dummy parameters within your batch file which DOS |
- | will replace with values you supply on the command line when exe- |
- | cuting the file. Using replaceable parameters allows you to specify |
- | DIFFERENT sets of data every time you run the batch file. You can |
- | use up to 10 parameters; if more are needed, the shift command (SEE |
- | SHIFT.HLP)can be used to extend the available set. Note that OTHER |
- | areas in the batch file can recognize the %X parameters as well.For |
- | example, you might want a message: ECHO ...WORK COMPLETE ON %1 |
- | the batch file would repeat the message but replace %1 with the name|
- | you typed on the command or prompt line. Examine the .BAT files on |
- | this disk to see many examples of how this is accomplished. |
- | Another example of replaceable parameters is shown below: |
- | |
- | FINDIT B: ROUND BLUE |
- | |
- | When you type in a command, the command itself (FINDIT) is para- |
- | meter %0. The parameter following the COMMAND (B:) is %1, and so on.|
- | In the example, therefore, ROUND=%1 and BLUE=%2 (a % for each word) |
- | All parameters following the cmd.take on succesive parameter values.|
- | |
- | Here is another way to illustrate parameters (the loop file): |
- | LOOP MYDEMO.DOC |
- | REM - LOOP BATCH FILE FOR %1 |
- | TYPE %1 |
- | . |
- | . (MYDEMO.DOC {%!} is displayed) |
- | . |
- | CLS |
- | LOOP |
- | REM - LOOP BATCH FILE FOR %1 |
- | . |
- | . (FILE IS DISPLAYED again) |
- | . |
- | FILE WILL KEEP GOING UNTIL YOU CTRL C OR CTRL-BREAK |
- | |
- | While not particularly useful,this batch file serves to demonstrate |
- | replaceable parameters. There are a few ways in which such a file |
- | (looping batch file) like the one above could be used. It could |
- | continuously run a software demonstration package or graphics |
- | animation program with a loop. You could also test the integrity of |
- | hardware by running a continuous test program over and over until |
- | you stopped it. |
- | |
- | Here's an experiment with replaceable parameters you can try: |
- | (Create the following file) |
- | COPY CON:SEEFILE.BAT |
- | TYPE %1 |
- | TYPE %2 |
- | TYPE %3 |
- | <F6> <RETURN> |
- | This batch file will display,using TYPE,the files that you specify |
- | as the first,second, and third parameters on the command line. Each |
- | filename.ext type would be typed in the order requested, on the CRT.|
- | screen. You could also use *.* (wildcards) as %1 and it would dis- |
- | play a whole group of files ( or *.DOC to display THOSE files). You |
- | could also use *.DOC as %1; *.TXT as %2, etc. When you use MULTIPLE |
- | PARAMETERS in a batch file they MUST be separated by spaces. To ill-|
- | ustrate:Often you have repetitive tasks which are quite similar,per-|
- | haps differing only by the file being processed. A parameter is used|
- | to provide a file name to the .BAT file. This way, a batch file can |
- | immediately perform a task for you without having to be specially |
- | edited to match your current needs. For example, INFORM.BAT : |
- | |
- | On monday: |
- | INFORM THUR.DAT FRI.DAT SAT.DAT SUN.DAT |
- | On thursday: |
- | INFORM MON.DAT TUE.DAT WED.DAT |
- | Up to 10 parameters may be used. Our example, INFORM.BAT would have |
- | a command line in its body. It could be COPY %1 + %2 + %3 + %4=A:RE-|
- | PORT (which would copy the files into ONE called REPORT which could |
- | then be renamed whatever you wanted). Or you could give a PRINT cmd.|
- | such as: PRINT %1 %2 %3 %4. There is no limit to your instructions. |
- | REVIEW THE .BAT FILES ON THIS DISK WITH PARAMETERS |
- | |
- | There may be times when you want to create an application program |
- | and run it with different sets of data. This data may be stored |
- | in various DOS files. Let's illustrate this & then examine our work.|
- | For example, when you type the command line COPY CON DOFILE.BAT, |
- | the next lines you type are copied from the console to a file named |
- | DOFILE.BAT on the default drive: |
- | COPY CON DOFILE.BAT |
- | COPY %1.INF+%2.INF=%2.PRN |
- | TYPE %2.PRN |
- | PRINT %2.PRN |
- | Now press <F6> or <ctrl/z> and then press <return>. DOS responds: |
- | "1 file(s) copied" |
- | The file DOFILE.BAT, which consists of three commands, now resides |
- | on the disk in the default drive. It stands ready for variables! |
- | The dummy parameters %1 and %2 are replaced sequentially by the |
- | parameters you supply when you execute the file. The dummy parameter|
- | %0 is always replaced by the drive designator, if specified, and |
- | the filename of the batch file (for example:DOFILE).Now let's do it!|
- | To execute the batch file DOFILE.BAT and to specify the parameters |
- | that will replace the dummy param.(markers),you must type the batch |
- | file name(without its extension) followed by the parameters you |
- | want DOS to substitute for %1, %2, etc. Let's look at what happens: |
- | |
- | (Remember that the file DOFILE.BAT consists of 3 lines): |
- | COPY %1.INF+%2.INF=%2.PRN
- | TYPE %2.PRN |
- | PRINT %2.PRN |
- | To execute the batch processing file, DOFILE you might type: |
- | DOFILE A:DATA1 B:DATA2 |
- | DOFILE is substituted for %0, A:DATA1 for %1, and B:DATA2 for %2. |
- | (notice how the drives can be inserted) |
- | The result is the same as if you had typed each of the commands in |
- | DOFILE with their parameters, as follows: |
- | COPY A:DATA1.INF+B:DATA2.INF=DATA2.PRN [COPY DATA1&DATA2=DATA2.PRN] |
- | TYPE B:DATA2.PRN [DISPLAYING THE COMBINED FILE] |
- | PRINT B:DATA2.PRN [PRINT THE COMBINED FILE] |
- | The following illustrates how DOS replaces each of the parameters: |
- | BATCH PARAMETER1 (%0) PARAMETER2 (%1) PARAMETER3 (%2) |
- | FILENAME (DOFILE) (DATA1) (DATA2) |
- | DOFILE DOFILE.BAT DATA1.INF DATA2.INF |
- | DATA2.PRN |
- | |
- | NOTES |
- | 1. Up to 10 dummy parameters (%0-%9) can be specified. Refer to the |
- | DOS command SHIFT if you wish to specify more than 10 parameters. |
- | 2. If you use the percent sign as part of a FILE NAME within a |
- | batch file, you must type it twice. For example, to specify the file|
- | XYZ%.BAT, you must type it as XYZ%%.BAT in the batch file. |
- | |
- |----------------- T I M E M A S T E R ---------------------|